import axios from '../utils/axios'

export const weather: () => Promise<any> = () => {
  return axios({
    url: '/api/weather',
    method: 'get'
  })
}

interface weatherModule {
  [key: string]: string
}
export const weatherIconZh: weatherModule = {
  '晴': 'icon-sun',
  '阴': "icon-icon-test",
  '多云': "icon-icon-test1",
  '中雨': "icon-icon-test2",
  '小雨': "icon-icon-test3",
  '大雨': "icon-icon-test4",
  '雷阵雨': "icon-icon-test5",
  '雨加冰雹': "icon-icon-test6",
  '特大暴雨': "icon-icon-test7",
  '暴雨': "icon-icon-test8",
  '小雪': "icon-icon-test9",
  '中雪': "icon-icon-test10",
  '雨夹雪': "icon-icon-test11",
  '大雪': "icon-icon-test12",
  '浮尘': "icon-icon-test13",
  '沙尘': "icon-icon-test14",
  '大暴雪': "icon-icon-test15",
  '雾': "icon-icon-test16",
  '雾霾': "icon-icon-test17",
  '飓风': "icon-icon-test18",
  '大风': "icon-icon-test19",
  '龙卷风': "icon-icon-test20",
  '风': "icon-icon-test21",
  '未知': "icon-icon-test22"
}

export const getWeatherIcon: (weather: string) => string = (weather = '晴') => {
  return weatherIconZh[weather] || 'icon-icon-test22'
}

export const hero: () => Promise<any> = () => {
  return axios({
    url: '/api/hero',
    method: 'get'
  })
}